package com.sunday.aomi.ui.main;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.flyco.tablayout.SlidingTabLayout;
import com.sunday.common.adapter.MainFragmentPagerAdapter;
import com.sunday.common.base.BaseFragment;
import com.sunday.aomi.R;
import com.sunday.aomi.ui.order.BuyOrderListFragment;
import com.sunday.aomi.ui.order.SellOrderListFragment;
import com.sunday.member.constv.ConstValue;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by 刘涛 on 2017/5/22.
 * <p>
 * 配送
 */

public class TransferFragment extends BaseFragment {


    @Bind(R.id.title)
    TextView title;
    @Bind(R.id.slide_tab)
    SlidingTabLayout slideTab;
    @Bind(R.id.view_pager)
    ViewPager viewPager;

    private ArrayList<Fragment> fragments = new ArrayList<>();
    private int pageNo;

    public static TransferFragment newInstance() {
        TransferFragment fragment = new TransferFragment();
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_transfer, container, false);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        title.setText("配送");
        initView();
    }


    private void initView() {
        fragments.add(SellOrderListFragment.newInstance(ConstValue.ORDER_TYPE_FOUR, ConstValue.STA_TWO));
        fragments.add(SellOrderListFragment.newInstance(ConstValue.ORDER_TYPE_FOUR, ConstValue.STA_THREE));
        fragments.add(SellOrderListFragment.newInstance(ConstValue.ORDER_TYPE_FOUR, ConstValue.STA_ZERO));
        viewPager.setAdapter(new MainFragmentPagerAdapter(getChildFragmentManager(), mContext, fragments,
                R.array.sell_order_list_title));
        slideTab.setViewPager(viewPager);
        viewPager.setCurrentItem(pageNo, false);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
